package mk.Compare;

import java.io.*;
import java.util.LinkedList;
import java.util.List;
import difflib.*;
/**
 * Created by mkiryluk on 2014-11-30.
 */
public class FileComparator {

    // Helper method for get the file content
    private static List<String> fileToLines(String filename) {
        List<String> lines = new LinkedList<String>();
        String line = "";
        try {
            BufferedReader in = new BufferedReader(new FileReader(filename));
            while ((line = in.readLine()) != null) {
                lines.add(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return lines;
    }

    public static void main(String[] args) {
        List<String> original = fileToLines("D:\\fileOne.txt");
        List<String> revised  = fileToLines("D:\\fileTwo.txt");

        // Compute diff. Get the Patch object. Patch is the container for computed deltas.
        Patch patch = DiffUtils.diff(original, revised);

        for (Delta delta: patch.getDeltas()) {
            System.out.println("File One : "+delta.getOriginal()+"  File Two : "+delta.getRevised());

        }
    }

}
